package logic

import (
	"svvenus/conf"
	"svvenus/util/uttype"
	"svvenus/vpub/serve"
	"svvenus/znet/zpb"
)

// MoneyValue
// @Description: 货币值
// @receiver player
// @param tp
// @return int64
func (player *Player) MoneyValue(tp int) int64 {
	v, ok := player.Moneys[uttype.IntToString(tp)]
	if ok {
		return v
	} else {
		return 0
	}
}

// MoneyHas
// @Description: 拥有货币
// @receiver player
// @param tp
// @param value
// @return bool
func (player *Player) MoneyHas(tp int, value int64) bool {
	return player.MoneyValue(tp) >= value
}

// MoneyChange
// @Description: 货币改变
// @receiver player
// @param tp
// @param value
// @param sor
func (player *Player) MoneyChange(tp int, value int64, sor zpb.RecSource) {
	if value == 0 {
		return
	}
	if value > 0 {
		player.MoneyAdd(tp, value, sor)
	} else {
		player.MoneyDel(tp, -value, sor)
	}
}

// MoneyAdd
// @Description: 货币产生
// @receiver player
// @param tp
// @param value
// @param sor
func (player *Player) MoneyAdd(tp int, value int64, sor zpb.RecSource) {
	if value < 0 {
		return
	}
	player.Moneys[uttype.IntToString(tp)] += value
	serve.RecordAdd(zpb.RecType_rtPlayerMoneyAdd, sor, player.IdString(), player.Name, uttype.IntToString(tp), uttype.Int64ToString(value))
}

// MoneyDel
// @Description: 货币消耗
// @receiver player
// @param tp
// @param value
// @param sor
func (player *Player) MoneyDel(tp int, value int64, sor zpb.RecSource) {
	if value < 0 {
		return
	}
	player.Moneys[uttype.IntToString(tp)] -= value
	serve.RecordAdd(zpb.RecType_rtPlayerMoneyDel, sor, player.IdString(), player.Name, uttype.IntToString(tp), uttype.Int64ToString(value))
}

// VitalityMax
// @Description: 体力最大值
// @receiver player
// @return int64
func (player *Player) VitalityMax() int64 {
	//todo 这里可能根据等级有变化
	return conf.V玩家最大体力
}

// VitalityRecoverValue
// @Description: 体力自动恢复值
// @receiver player
// @return int64
func (player *Player) VitalityRecoverValue() int64 {
	return conf.V玩家体力回复每次
}
